package com.qf.controller;

import com.qf.pojo.Books;
import com.qf.pojo.Permission;
import com.qf.pojo.req.BookType;
import com.qf.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 作者：冯国清
 * 项目名：com.qf.controller
 * 时间：2020/8/20 10:28
 * 描述:
 */
@RestController
public class PermissionController {
    @Autowired
    private PermissionService permissionService;
    @RequestMapping("/findPermissionBypid/{pid}")
    public Permission findPermissionBypid(@PathVariable("pid")Integer pid){
        return permissionService.findPermissionBypid(pid);
    }
    @RequestMapping("/findAllPermission")
    public List<Permission> findAllPermission(){
        return permissionService.getAllPermission();
    }

    @RequestMapping(value = "/addPermission",method = RequestMethod.POST)
    public int addPermission(@RequestBody Permission permission){
        int add = permissionService.add(permission);
        if (add>0){
            return 1;
        }else {
            return 0;
        }
    }
    @RequestMapping(value = "/updatePermission",method = RequestMethod.POST)
    public int updateBooks(@RequestBody Permission permission){
        int update = permissionService.update(permission);
        if (update>0){
            return 1;
        }else {
            return 0;
        }
    }

    @RequestMapping("/deletePermission/{pid}")
    public int deletePermission(@PathVariable("pid")int pid) {
        int delete = permissionService.delete(pid);
        if (delete>0){
            return 1;
        }else {
            return 0;
        }
    }
}
